<div id="blogSideL">
<?php 
if(!empty($previousBlog)){
	echo "<a href='bloglist.php?blogId={$previousBlog[0][0]}' title='{$previousBlog[0][1]}'><img src='style/btnL_1.png' /></a>";
	echo "<script>var blogLeftId = {$previousBlog[0][0]}</script>";
}
?>
</div>
<div id="blogSideLContent"></div>
<div id="blogsingle"> <!--start of blogsingle-->
	<ul class="bloghead">
		<li class="li1">文章查看</li>
		<li class="li2"><a href="blog.php">写新文章</a></li>
	</ul>
<?php
if (!empty($blogs)){
	$i=0;
	//display blogs
	foreach ($blogs as $key=>$values){
		$blogId=$values[0];
		echo "<div class='blogiterm' id ='blogId$blogId'>";//start one blog
		echo "<h2><img src='style/fam_page_white.gif' /> <a href='bloglist.php?blogId=$blogId'>".$values["title"]."</a></h2>";
		$blogUser = $usernumbers[$i];
		echo "<div class='blogtime'>$blogUser&nbsp;&nbsp;".$values['postTime']."</div>";
		$content = $values["content"];
		echo "<div class='blogtext'>$content</div>";
		//get this blog kind
		$tKind =$kinds[$i];
		$i++;
		$managdata ="&nbsp;&nbsp;|&nbsp;&nbsp;<a href='blog.php?blogId=$blogId'>编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick =blogDelete('$blogId') class='blogdeletebutton'>删除</a>";
		$blogNumbers = $page->getKindBlogNumbers($tKind);
		$tKindId =$page->getBlogKindContent($tKind);
		if (!$profileID){
			$modiPro = 1;
			$profileID = $page->getBlogOwner($blogId);
		}
		
		echo "<div class='blogmanagediv'>类别&nbsp;:&nbsp;&nbsp;<a href=bloglist.php?userId=$profileID&blogKind=$tKindId>".$tKind."</a>（".$blogNumbers."）";
		if($modiPro){
			$profileID = "";
		}
		$blogOwnerId = $values["userId"];
		if($blogOwnerId==$userId){
			echo $managdata;
		}
		echo "&nbsp;&nbsp;|&nbsp;&nbsp;<a href='bloglist.php?blogId=$blogId'>浏览（$values[view]）</a></div>";
		echo "<ul class='nextpreviousBlog'>";
		if(!empty($previousBlog)){
			echo "<li class='firstBlog'><a href='bloglist.php?blogId={$previousBlog[0][0]}'>&lt;&lt;&lt;&nbsp;{$previousBlog[0][1]}</a></li>";
		}
		if(!empty($nextBlog)){
			echo "<li class='nextBlog'><a href='bloglist.php?blogId={$nextBlog[0][0]}'>{$nextBlog[0][1]}&nbsp;&gt;&gt;&gt;</a></li>";
		}
		echo "</ul>";
		echo "</div>";//end one blog
	}
}else {
	echo "该文章不存在或已被删除";
}
?>
</div><!-- end of blogsingle-->
<div id="blogSideR">
<?php 
if(!empty($nextBlog)){
	echo "<a href='bloglist.php?blogId={$nextBlog[0][0]}' title='{$nextBlog[0][1]}'><img src='style/btnR_1.png' /></a>";
	echo "<script>var blogRightId = {$nextBlog[0][0]}</script>";
}
?>
</div>
<div id="blogSideRContent"></div>
<script type="text/javascript">
	window.zindexhandle = 3;
	/* $(window).scroll( function() {
		var scrollY = document.body.scrollTop || document.documentElement.scrollTop;
		var scrollX = document.body.scrollLeft || document.documentElement.scrollLeft;
		var top = ($(window).height())/2+scrollY;
		//var top = top;
		var left = ($(window).width())+scrollX-40;
		$("#blogSideL").css({"top":top});
		$("#blogSideR").css({"top":top,"left":left});
	}) */
	var scrollX = document.body.scrollLeft || document.documentElement.scrollLeft;
	var scrollY = document.body.scrollTop || document.documentElement.scrollTop;
	var top = ($(window).height())/2+scrollY;
	//var top = (top)/2;
	var left = ($(window).width())/* +scrollX */-50;
	var blogSideL = $("#blogSideL");
	blogSideL.css({"left":"0px","top":top});
	window.idHandle="0";
	window.divHandle="0";
	blogSideL.click(function(){idHandle=blogLeftId,divHandle="blogSideLContent"});
	/*blogSideL.click(displaySideBlog);*/
	$("#blogSideLContent").mouseover(function(){
		zindexhandle++;
		$("#blogSideLContent").css({"z-index":zindexhandle});
	});

	var blogSideR = $("#blogSideR");
	blogSideR.css({"left":left,"top":top});
	blogSideR.click(function(){idHandle=blogRightId,divHandle="blogSideRContent"});
	/*blogSideR.click(displaySideBlog);*/
	$("#blogSideRContent").mouseover(function(){
		zindexhandle++;
		$("#blogSideRContent").css({"z-index":zindexhandle});
	});
	function displaySideBlog(){
		if(divHandle=="blogSideLContent"){
			var test = $("#blogSideLContent").html();
			if(test){
				$("#blogSideLContent").animate({width:"0",height:"0"},1000,function(){
				$("#blogSideLContent").html("");
				$("#blogSideLContent").css({"display":"none","height":"auto"});
				});
				return false;
			}
		}else{
			var test = $("#blogSideRContent").html();
			if(test){
				$("#blogSideRContent").animate({width:"0",height:"0"},1000,function(){
				$("#blogSideRContent").html("");
				$("#blogSideRContent").css({"display":"none","height":"auto"});
				});
				return false;
			}
		}
		$.ajax({
			type:"POST",
			url:"blogSideAjax.php",
			data:{blogId:idHandle},
			success:function(data){
				var scrollY = document.body.scrollTop || document.documentElement.scrollTop;
				//var scrollX = document.body.scrollLeft || document.documentElement.scrollLeft;
				var top = ($(window).height())/3+scrollY-150;
				//var left = ($(window).width())+scrollX-50;
				zindexhandle++;
				if(divHandle=="blogSideLContent"){
					$("#"+divHandle).html(data);
					$("#"+divHandle).css({"display":"block","z-index":zindexhandle});
					$("#"+divHandle).animate({width:"900px",left:"50px",top:top},1000);
					
				}else{
					$("#"+divHandle).html(data);
					$("#"+divHandle).css({"display":"block","z-index":zindexhandle});
					$("#"+divHandle).animate({width:"900px",left:"200px",top:top},1000);
				}
			}
		});
	}
	function closeBlogSide(para){
		var Node = para.parentNode;
		$(Node).animate({width:"0",height:"0"},1000,function(){
			$(Node).html("");
			$(Node).css({"display":"none","height":"auto"});
		});
		
	}
</script>